use serde_derive::{Serialize, Deserialize};
use lucky::{
    models::{UserDetailRow as ModelRow},
    json::JsonPager
};
use sqlx::{postgres::{PgRow}, row::Row,};
use crate::common::{Pool, models::BackendModel};

#[derive(Serialize, Deserialize, Debug)]
pub struct UserDetail;


impl BackendModel<ModelRow> for UserDetail { 
        
    const TABLE_NAME: &'static str = "user_details";
    const FIELDS: &'static str = "id, user_id, user_name, birth, gender, phone, photo, mail, address, remark";

    fn get_row_filter(r: &PgRow) -> ModelRow {
        unfold_fields!(r, {
            id => i32,
            user_id => i32,
            user_name => String,
            gender => i16,
            photo => String,
            phone => String,
            mail => String,
            address => String,
            remark => String,
        }, {}, {}, {birth,})
    }
}

impl UserDetail {
    record_list!();
}
